{% extends "_base.html" %}

{% block main %}
<script>
    $(function () {
        $('#answerForm').submit(function (e) {
            e.preventDefault();
            var data = {
                responder_id: $('#accountID').val(),
                content: $('#floatingTextarea2').val()
            };
            $.ajax({
                type: 'post',
                url: '/postAnswer',
                data: JSON.stringify(data),
                success: function (resp) {
                    if (resp.error) {
                        $('#error').text(resp.error);
                    } else {
                        location.assign('/');
                    }
                },
                contentType: 'application/json',
                dataType: 'json'
            });
        });
    });
</script>

<ul class="nav justify-content-center">
    <li class="nav-item">
        <a class="nav-link active" aria-current="page" href="index.html">首页</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="login.html">登录</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="register.html">注册</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="account.html" tabindex="-1" aria-disabled="true">我的</a>
    </li>
</ul>

<form id="answerForm">
<div class="container">
    <div class="form-floating">
        <input id="accountID" type="text" style="display:none; color:  #fdfdfe" value="{{account.accountID}}" >
        <textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 100px"></textarea>
        <label for="floatingTextarea2">回答写这里...</label>
    </div>
    <button type="submit" class="btn btn-primary" style="float: right;margin-top: 20px;">回答</button>
</div>
</form>
{% endblock %}
